# 迭代器 面向对象  https://www.runoob.com/python3/python3-class.html

#类

class MyCalss:
	age = 8
	__name = 'bb'   # __ 带下划线的为私有变量
	def getAge(self):
		return 'myAge?'

	


#类中的函数定义需要 self 传入 代码类的实例

#实例化
my = MyCalss()

#使用方法和访问属性 
print(my.getAge())
print(my.age)

#自定义构造
class SecondClass:
	def __init__(self,num):  
		self.age = num
	
second = SecondClass(2)
print(second.age)


#继承 多继承  方法重写  #== em 

class Person:
	def __init__(self,age,name):
		self.age = age
		self.name = name
	def getType(self):
		print("i am person")

class Man(Person):
	# 调用父类的构造
	def __init__(self,age,name):
		Person.__init__(self,age,name)
	# 直接覆盖父类的方法
	def getType(self):
		print("i am man")

manOne = Man(18,'peter')
print(manOne.getType())
print(manOne.age)

#多继承
class FlyCalss:
	def getFly(self):
		print("i can fly")

class SuperMan(Person,FlyCalss):
	def __init__(self,age,name):
		Person.__init__(self,age,name)
	def getType(self):
		print("i am superMan")

superMan = SuperMan(99,'hero')
print(superMan.getFly())
